/********************************************************************************
TITLE:                      	Using Virtual Functions
FILENAME:                   	media.cpp
PREPARED FOR:               	CS215 Section CS13-02
PROGRAMMER(S):              	Eric (Fox) Crowell, Timothy Drye
DEVELOPMENT DATE:           	< 12/15/13 >
COMPILER USED:      			Microsoft Visual Studio Professional 2013
- Version 12.0.21005.1 REL
TARGET PLATFORM:         	    Windows 8 x64
================================================================================
REVISION HISTORY

DATE         PROGRAMMER          DESCRIPTION OF CHANGES MADE
------------------------------------------------------------------------------
<12/15/13       Fox                 CPP File created.                        >

*******************************************************************************/

#include "media.h"

// Default constructor [Fox]
Media::Media() {
	//Temporary storage of hours and minutes for Time object. [Fox]
	int hours, minutes;
	// Promts the user to input data about the new media object. [Fox]
	cout << "      --------------------------------------------------\n";
	cout << "      CREATE NEW MEDIA ITEM \n";
	cout << "      --------------------------------------------------\n";
	cout << "      --- Title: ";
	cin.ignore(cin.rdbuf()->in_avail());
	getline(cin, Title); // String
	cin.ignore(cin.rdbuf()->in_avail());
	cout << "      --- Artist: ";
	getline(cin, Artist); // String
	cin.ignore(cin.rdbuf()->in_avail());
	cout << "      --- Purchased From: ";
	getline(cin, WherePurchased); // String
	cin.ignore(cin.rdbuf()->in_avail());
	cout << "      --- Cost: ";
	cin >> Cost; // Float type only!
	cout << "      --- Running Time (Hours): ";
	cin >> hours; // Integer only!
	cout << "      --- Running Time (Minutes): ";
	cin >> minutes; // Integer only!

	RunningTime.SetTime(hours, minutes);
}

// Overloaded constructor [Fox]
Media::Media(const string  & InTitle, const string & InArtist, const string & InWherePurchased,
	float InCost, Time  & InRunningTime) {
	Title = InTitle;
	Artist = InArtist;
	WherePurchased = InWherePurchased;
	Cost = InCost >= 0 ? InCost : 0;
	RunningTime = InRunningTime;
}

// Returns the "Title" data member [Fox]
string Media::GetTitle() const {
	return(Title);
}

// Returns the "Artist" data member [Fox]
string Media::GetArtist() const {
	return(Artist);
}

// Returns the "WherePurchased" data member [Fox]
string Media::GetWherePurchased() const {
	return(WherePurchased);
}

// Returns the "Cost" data member [Fox]
float Media::GetCost() const {
	return(Cost);
}

// Returns the "RunningTime" data member [Fox]
Time Media::GetRunningTime() const {
	return(RunningTime);
}

/* These vitual functions will be overwritten in children of this class
// Plays the current track [Fox]
void Media::Play() {

}

// Goes to the end of the current track [Fox]
void Media::FastForward() {

}

// Goes to the beginning of the track [Fox]
void Media::Rewind() {

}
*/

// Prints information about this media [Fox]
void Media::PrintMedia(ostream & Out) {
	// Format cost output
	ostringstream costStream;
	costStream << fixed << setprecision(2) << "$" << Cost;
	// Output all information.
	Out << "      --------------------------------------------------\n";
	Out << "      MEDIA INFORMATION \n";
	Out << "      --------------------------------------------------\n";
	Out << "      --- Title: " << Title << "\n";
	Out << "      --- Artist: " << Artist << "\n";
	Out << "      --- Purchased From: " << WherePurchased << "\n";
	Out << "      --- Cost: " << costStream.str() << "\n";
	Out << "      --- Running Time: " << RunningTime << "\n";
}